package com.koron.css2.serviceManage.impl;

import com.koron.css2.ServerInterface;
import com.koron.css2.serviceManage.bean.RequestBean;
import com.koron.css2.serviceManage.bean.ServerAreaBean;
import com.koron.css2.serviceManage.bean.UserInfoBean;
import com.koron.css2.serviceManage.mapper.PubServerAreaMapper;
import com.koron.util.Constant;
import com.koron.util.JsonUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.koron.ebs.mybatis.SessionFactory;
import org.swan.bean.MessageBean;

/**
 * 服务区域配置-修改
 *
 * @author 甄玉晴
 */
public class ServerAreaUpdate implements ServerInterface {

    private static Logger logger = LogManager.getLogger(ServerAreaUpdate.class);

    @Override
    public MessageBean<?> exec(SessionFactory factory, UserInfoBean userInfo, RequestBean req) {
        try {
        	PubServerAreaMapper mapper = factory.getMapper(PubServerAreaMapper.class);
            ServerAreaBean bean = JsonUtils.objectToPojo(req.getData(), ServerAreaBean.class);
            bean.setUpdateInfo(userInfo);
            mapper.update(bean);
        } catch (Exception e) {
            logger.error("服务区域配置修改失败", e);
            return MessageBean.create(Constant.ILLEGAL_PARAMETER, "服务区域配置修改失败", void.class);
        }
        return MessageBean.create(Constant.MESSAGE_INT_SUCCESS, "success", void.class);
    }
  
}